/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Parser;

import java.util.ArrayList;
import lowlevel.Function;

/**
 *
 * @author Tyler Helmuth + Max Muhlenkamp
 */
public class CompoundStmt extends Statement{
    ArrayList<Vardecl> localDeclarations;
    ArrayList<Statement> statements;
    
    public CompoundStmt(ArrayList<Vardecl> decls, ArrayList<Statement> statements){
        this.localDeclarations = decls;
        this.statements = statements;
    }

    @Override
    void print(String indent) {
        CMinusParser.oFile.println(indent + "CompoundStatement:");
        CMinusParser.oFile.println(indent + "  Local Declarations:");
        if(localDeclarations == null){
            CMinusParser.oFile.println(indent + "    null");
        }
        else{
            for(int i = 0; i < localDeclarations.size(); i++){
                localDeclarations.get(i).print(indent + "    ");
            }
        }
        CMinusParser.oFile.println(indent + "  Statements:");
        if(statements == null){
            CMinusParser.oFile.println(indent + "    null");
        }
        else{
            for(int i = 0; i < statements.size(); i++){
                statements.get(i).print(indent + "    ");
            }
        }
        CMinusParser.oFile.flush();
    }
    public void genLLCode(Function func){
        for(Vardecl d : localDeclarations){
            d.genLLCode(func);
        }
        for(Statement s : statements){
            s.genLLCode(func);
        }
    }
}
